package week2
import org.apache.spark.{SparkContext,SparkConf}
import  org.apache.spark.SparkContext
object SogoQA {
  def main(args: Array[String]) {
    if(args.length ==0){
      System.err.println("usage: SogoQA <file1><file2>")
      System.exit(1)
    }
    val conf=new SparkConf().setAppName("wordcount1")
    val sc=new SparkContext(conf)
    sc.textFile(args(0)).map(_.split("\t")).filter(_.length==6).map(x=>(x(1),1)).reduceByKey(_+_).map(x=>(x._2,x._1)).sortByKey(false).map(x=>(x._2,x._1)).saveAsTextFile(args(1))
    sc.stop()
  }
}
